JBoss Community Archive (Read Only)

ModeShape 4

ModeShape's WebDAV Service

ModeShape offers a WebDAV service which allows any WebDAV compliant clients to interact with the repository, mainly around managing files and folders. Although this represents a relatively small subset of the repository's capabilities, it may prove useful in certain situations.

Configuration

Depending on whether you want to use the WebDAV service in the JBoss Application Server or another web server, there are 2 different options:

Embedded

To embed the WebDAV service in your own application, you need to use the modeshape-web-jcr-webdav-war artifact which comes pre-packaged with all the default dependencies (including ModeShape). The easiest way to use & customize this is to first add the artifact as a dependency in your project:

<dependency>
  <groupId>org.modeshape</groupId>
  <artifactId>modeshape-web-jcr-webdav-war</artifactId>
  <type>war</type>
  <scope>runtime</scope>
</dependency>

after which you need to overwrite (overlay) your own web.xml, repository configuration and optional additional dependencies. The former is the most important as it contains a reference towards your own custom repository configuration:

<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
    <display-name>ModeShape JCR WebDAV Interface Custom Configuration</display-name>

    <!--
         This parameter defines the location of the configuration file, or can specify
         the JNDI location of the Repository or Repositories implementation.
         (If the object in JNDI is a ModeShape Repositories instance, then this web application
         will support multiple repositories.)

         If a file is specified, ModeShape will first check for a file at this path in the filesystem.
         If not file exists at this path, ModeShape will attempt to load this as a resource
         from the classpath.

         The JNDI location can be specified in the form jndi:<jndi_name>
     -->
    <context-param>
        <param-name>org.modeshape.jcr.URL</param-name>
        <param-value>file:/my-repository-config.json</param-value>
    </context-param>

    <!--
         Nodes with any of the primary node types in this comma-delimited list will be treated by the
         WebDAV implementation as content nodes.  The value below is the default value for this
         parameter.  That is, if this init parameter is omitted, the value below will be used by default.
     -->
    <context-param>
        <param-name>org.modeshape.web.jcr.webdav.CONTENT_PRIMARY_TYPE_NAMES</param-name>
        <param-value>nt:resource, mode:resource</param-value>
    </context-param>

    <!--
         Nodes with any of the primary node types in this comma-delimited list will be treated by the
         WebDAV implementation as resource (file) nodes.  The value below is the default value for this
         parameter.  That is, if this init parameter is omitted, the value below will be used by default.
     -->
    <context-param>
        <param-name>org.modeshape.web.jcr.webdav.RESOURCE_PRIMARY_TYPE_NAMES</param-name>
        <param-value>nt:file</param-value>
    </context-param>

    <!--
         Each folder created through the WebDAV servlet will be created as a node with the primary node
         type below.  The value below is the default value for this parameter.  That is, if this init
         parameter is omitted, the value below will be used by default.
     -->
    <context-param>
        <param-name>org.modeshape.web.jcr.webdav.NEW_FOLDER_PRIMARY_TYPE_NAME</param-name>
        <param-value>nt:folder</param-value>
    </context-param>

    <!--
         Each resource (file created through the WebDAV servlet will be created as a node with the primary
         node type below.  The value below is the default value for this parameter.  That is, if this init
         parameter is omitted, the value below will be used by default.
     -->
    <context-param>
        <param-name>org.modeshape.web.jcr.webdav.NEW_RESOURCE_PRIMARY_TYPE_NAME</param-name>
        <param-value>nt:file</param-value>
    </context-param>

    <!--
         Content created through the WebDAV servlet will be created as a node with the primary node
         type below.  The value below is the default value for this parameter.  That is, if this init
         parameter is omitted, the value below will be used by default.
     -->
    <context-param>
        <param-name>org.modeshape.web.jcr.webdav.NEW_CONTENT_PRIMARY_TYPE_NAME</param-name>
        <param-value>nt:resource</param-value>
    </context-param>

    <!-- Required parameter for ModeShape WebDAV - should not be modified -->
    <listener>
        <listener-class>org.modeshape.web.jcr.ModeShapeJcrDeployer</listener-class>
    </listener>

    <!-- Required WebDAV servlet - should not be modified -->
    <servlet>
        <servlet-name>WebDAV</servlet-name>
        <servlet-class>org.modeshape.web.jcr.webdav.ModeShapeWebdavServlet</servlet-class>

        <!--
              The webdav library requires this parameter to be present, but does not use it.
          -->
        <init-param>
            <param-name>rootpath</param-name>
            <param-value>.</param-value>
        </init-param>
    </servlet>

    <!-- Required parameter for ModeShape WebDAV - should not be modified -->
    <servlet-mapping>
        <servlet-name>WebDAV</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

Maven automatically overlays dependencies of type war, so all you need to do is make sure your project structure contains the correct paths: src/main/resource and src/main/webapp/WEB-INF/web.xml.

See also our examples for such a configuration.

JBoss Wildfly

Once installed into Wildfly, the ModeShape Wildfly kit provides the WebDAV service out-of-the-box, via a web application named modeshape-webdav.war. This application is configured by default via the standalone-modeshape.xml server configuration file and allows access to all the repositories configured & deployed via Wildfly.

        <subsystem xmlns="urn:jboss:domain:modeshape:2.0">
            <!--The list of web applications that is packaged inside the kit and should be deployed when the subsystem starts up-->
            <webapp name="modeshape-webdav.war"/>
        </subsystem>

See also Using Repositories with WebDAV in Wildfly

By default, both web applications use Basic HTTP Authentication and require a role named connect to be present in the authenticated user's set of roles.

JBoss.org Content Archive (Read Only), exported from JBoss Community Documentation Editor at 2020-03-11 12:09:59 UTC, last content change 2014-11-10 12:37:50 UTC.